package com.example.fileserver.controller;

import com.example.fileserver.entity.R;
import com.example.fileserver.client.fastdfs.FastdfsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author yousj
 * @date 2021/8/1
 */
@RestController
@RequestMapping("/fastdfs")
public class FastdfsFileController {

    @Autowired
    FastdfsUtil fastdsfUtil;

    @PostMapping("/upload")
    public R upload(MultipartFile file) throws Exception {
        return R.isOk(fastdsfUtil.upload(file));
    }

    @GetMapping("/deleteFile")
    public void deleteFile(@RequestParam(value = "fileUrl") String fileUrl){
        fastdsfUtil.deleteFile(fileUrl);
    }
}
